package si.yun.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestParam;
import si.yun.dao.*;
import si.yun.entity.*;
import si.yun.service.SyOperationService;
import si.yun.utils.*;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * @ClassName: 栾佳俊
 * @Description: TODO
 * @Author: 空白
 * @Date 2021/7/29 13:55
 */
@PropertySource("classpath:config.properties")
@Service
public class SyOperationServiceImpl implements SyOperationService {
    @Value("${path1}")
    private String path1;
    @Autowired
    private si.yun.dao.SyUserOrderMapper SyUserOrderMapper;
    @Autowired
    private SyUserAccountFlowMapper dao;
    @Autowired
    private SyCourseMapper Mapper;
    @Autowired
    private si.yun.dao.SyProductMapper SyProductMapper;
    @Autowired
    private si.yun.dao.SyProductCategroyMapper SyProductCategroyMapper;
    @Autowired
    private SyUserMapper syUserMapper;
    @Autowired
    private si.yun.dao.OpeHomeDao OpeHomeDao;
    //优惠券
    @Autowired
    public SyUserCouponMapper syUserCouponMapper;
    //优惠券记录
    @Autowired
    public SyUserCouponUsedMapper syUserCouponUsedMapper;
    //轮播图记录
    @Autowired
    public SyCarouselMapper syCarouselMapper;
    @Autowired
    private SyMicrocircleImgMapper syMicrocircleImgMapper;
    @Autowired
    private SyCourseRecordMapper syCourseRecordMapper;
    @Autowired
    private si.yun.dao.SyProductCategroyMapper syProductCategroyMapper;
    @Autowired
    private SyUserCollectionMapper syUserCollection;
    //评论
    @Autowired
    public SyCommentMapper syCommentMapper;
	
	@Autowired
    public SyForumMapper syForumMapper;

    @Autowired
    private GuavaUtils baseCache;

    @Autowired
    private PersonnelDao personnelMapper;
	
	@Autowired
    public TestAliUpload testAliUpload;
    /**
     * @Author : 栾佳俊
     * @Date : 2021/8/2 14:54
     * @Param : []
     * @Return : int
     */
    @Override
    public int SelectSyOrder() {
        return dao.SelectSyOrder();
    }
    /**
     * @Author : 栾佳俊
     * @Date : 2021/8/2 14:54
     * @Param : []
     * @Return : int
     */
    @Override
    public int SelectSyPendingCourses() {
        return dao.SelectSyPendingCourses();
    }
    /**
     * @Author : 栾佳俊
     * @Date : 2021/8/2 14:54
     * @Param : []
     * @Return : int
     */
    @Override
    public int SelectSySales() {
        return dao.SelectSySales();
    }
    /**
     * @Author : 栾佳俊
     * @Date : 2021/8/2 14:54
     * @Param : []
     * @Return : int
     */
    @Override
    public int SelectSyPending() {
        return dao.SelectSyPending();
    }
    /**
     * @Author : 栾佳俊
     * @Date : 2021/8/2 14:54
     * @Param : []
     * @Return : int
     */
    @Override
    public int SelectSyCommodity() {
        return dao.SelectSyCommodity();
    }
    /**
     * @Author : 栾佳俊
     * @Date : 2021/8/2 14:54
     * @Param : [value]
     * @Return : java.util.List<java.lang.Integer>
     */
    @Override
    public List<Integer> SelectSyOrderStatistics(String value,List<String> timeDate) {
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
        try {
            sf.parse(value);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        String  dateNowStr="";
        if(value==null){
            Calendar cal = Calendar.getInstance();
            int year = cal.get(Calendar.YEAR);//获取年份
            int month=cal.get(Calendar.MONTH)+1;//获取月份
            int day=cal.get(Calendar.DATE);//获取日
            int day1=day-1;
            dateNowStr =year+"-"+month+"-"+day1+"";
        }else {
            dateNowStr=value;
        }
        for(int i=0;i<timeDate.size();i++){
            for (int cs=1;cs<=9;cs++){

            }
        }
        String parm=dateNowStr+"  "+"00:00:00";
        String parm2=dateNowStr+"  "+"03:00:00";
        String parm3=dateNowStr+"  "+"06:00:00";
        String parm4=dateNowStr+"  "+"09:00:00";
        String parm5=dateNowStr+"  "+"12:00:00";
        String parm6=dateNowStr+"  "+"15:00:00";
        String parm7=dateNowStr+"  "+"18:00:00";
        String parm8=dateNowStr+"  "+"21:00:00";
        String parm9=dateNowStr+"  "+"00:00:00";
        List list2=new ArrayList();
        list2.add(parm);
        list2.add(parm2);
        list2.add(parm3);
        list2.add(parm4);
        list2.add(parm5);
        list2.add(parm6);
        list2.add(parm7);
        list2.add(parm8);
        list2.add(parm9);
        List list = new ArrayList();
        for(int a = 1; a<list2.size(); a++) {
            String s= (String) list2.get(a-1);
            String s1= (String) list2.get(a);
            int i = dao.SelectSyOrderStatistics(s,s1);
            list.add(i);
        }
        return list;
    }
    /**
     * @Author : 栾佳俊
     * @Date : 2021/8/2 14:55
     * @Param : []
     * @Return : int
     */
    @Override
    public int SelectSyOrderDingDan() {
        return dao.SelectSyOrderDingDan();
    }
    /**
     * @Author : 栾佳俊
     * @Date : 2021/8/2 14:55
     * @Param : []
     * @Return : int
     */
    @Override
    public int SelectSyOrderDingDanMonery() {
        return dao.SelectSyOrderDingDanMonery();
    }
    /**
     * @Author : 栾佳俊
     * @Date : 2021/8/24 10:27
     * @Param : []
     * @Return : si.yun.utils.JsonData
     */
    @Override
    public int SyCourseOrderManagementselControllerAllOrders() {
        return SyUserOrderMapper.SyCourseOrderManagementselControllerAllOrders();
    }
    /**
     * @Author : 栾佳俊
     * @Date : 2021/8/24 10:27
     * @Param : []
     * @Return : si.yun.utils.JsonData
     */
    @Override
    public int SyCourseOrderManagementselControllerPendingPayment() {
        return SyUserOrderMapper.SyCourseOrderManagementselControllerPendingPayment();
    }
    /**
     * @Author : 栾佳俊
     * @Date : 2021/8/24 10:27
     * @Param : []
     * @Return : si.yun.utils.JsonData
     */
    @Override
    public int SyCourseOrderManagementselControllerCompleted() {
        return SyUserOrderMapper.SyCourseOrderManagementselControllerCompleted();
    }
    /**
     * @Author : 栾佳俊
     * @Date : 2021/8/24 10:27
     * @Param : []
     * @Return : si.yun.utils.JsonData
     */
    @Override
    public int SyCourseOrderManagementselControllerCancelled() {
        return SyUserOrderMapper.SyCourseOrderManagementselControllerCancelled();
    }
    /**
     * @Author : 栾佳俊
     * @Date : 2021/8/24 10:27
     * @Param : []
     * @Return : si.yun.utils.JsonData
     */
    @Override
    public List<SyUserOrder> SyCourseOrderManagementselControllerAllOrderReviewList() {
        return SyUserOrderMapper.SyCourseOrderManagementselControllerAllOrderReviewList();
    }
    /**
     * @Author : 栾佳俊
     * @Date : 2021/8/24 10:27
     * @Param : []
     * @Return : si.yun.utils.JsonData
     */
    @Override
    public List<SyUserOrder> SyCourseOrderManagementselControllerPendingPaymentList() {
        return SyUserOrderMapper.SyCourseOrderManagementselControllerPendingPaymentList();
    }
    /**
     * @Author : 栾佳俊
     * @Date : 2021/8/24 10:27
     * @Param : []
     * @Return : si.yun.utils.JsonData
     */
    @Override
    public List<SyUserOrder> SyCourseOrderManagementselControllerCompletedList() {
        return SyUserOrderMapper.SyCourseOrderManagementselControllerCompletedList();
    }
    /**
     * @Author : 栾佳俊
     * @Date : 2021/8/24 10:27
     * @Param : []
     * @Return : si.yun.utils.JsonData
     */
    @Override
    public List<SyUserOrder> SyCourseOrderManagementselControllerCanceledList() {
        return SyUserOrderMapper.SyCourseOrderManagementselControllerCanceledList();
    }
    /**
     * @Author : 栾佳俊
     * @Date : 2021/8/24 10:27
     * @Param : []
     * @Return : si.yun.utils.JsonData
     */
    @Override
    public List<SyUserOrder> SyCourseOrderManagementselControllerAllCourseOrderListView(SyUser syUser) {
        return SyUserOrderMapper.SyCourseOrderManagementselControllerAllCourseOrderListView(syUser);
    }
    /**
     * @Author : 栾佳俊
     * @Date : 2021/8/24 10:27
     * @Param : []
     * @Return : si.yun.utils.JsonData
     */
    @Override
    public List<SyUserOrder> AdvancedRetrievalOfCourseListPopUpLayer(SyUser syUser) {
        return SyUserOrderMapper.AdvancedRetrievalOfCourseListPopUpLayer(syUser);
    }

    /**
     * @Author : 栾佳俊
     * @Date : 2021/8/4 16:28
     * @Param : [str2, c, id]
     * @Return : si.yun.utils.JsonData
     */
    @Override
    public int SyCommodityReviewAdd(String str2,int c,int id) {
        return Mapper.SyCommodityReviewAdd(str2,c,id);
    }
    /**
     * @Author : 栾佳俊
     * @Date : 2021/8/4 16:28
     * @Param : [str2, c, id]
     * @Return : si.yun.utils.JsonData
     */
    @Override
    public int SyProductNameUpd(String str, int c, int id) {
        return Mapper.SyProductNameUpd(str,c,id);
    }

    /**
     * @Author : 栾佳俊
     * @Date : 2021/8/4 8:23
     * @Param : []
     * @Return : si.yun.utils.JsonData
     */
    @Override
    public List<SyCourse> SyCourseReview() {
        List<SyCourse> syCourses = Mapper.SyCourseReview();
        if(syCourses!=null){
            //使用增强for循环实现
            for(SyCourse item :syCourses){
                item.setUrl(path1+item.getUrl());
            }
        }
        return syCourses;
    }
    /**
     * @Author : 栾佳俊
     * @Date : 2021/8/4 8:23
     * @Param : []
     * @Return : si.yun.utils.JsonData
     */
    @Override
    public SyCourse SyCourseReviewXiangqing(int s) {

        return Mapper.SyCourseReviewXiangqing(s);
    }
    /**
     * @Author : 栾佳俊
     * @Date : 2021/8/4 8:23
     * @Param : []
     * @Return : si.yun.utils.JsonData
     */
    @Override
    public List<SyCourse> SyCourseReviewAdvancedSearch(String kecheng, int aClass, int aClass2) {
        List<SyCourse> syCourses = Mapper.SyCourseReviewAdvancedSearch(kecheng, aClass, aClass2);
        return syCourses;
    }

    @Override
    public List<HashMap> getProgect(String productName, Integer condition, String productLabel) {
        return null;
    }

    @Override
    public List<HashMap> SyCourseDatasheets() {
        List<HashMap> syProducts = SyProductMapper.SyCourseDatasheets();
        //使用增强for循环解决
        for(int i=0;i<syProducts.size();i++) {
            int c = (int) syProducts.get(i).get("category_id");
            SyProductCategroy syProductCategroys = SyCourseCategories(c);
            if(syProductCategroys!=null){
                String categroyName = syProductCategroys.getCategroyName();
                syProducts.get(i).put("categroyName", categroyName);
            }
        }
        return syProducts;

    }

    /**
     * @Author : 栾佳俊
     * @Date : 2021/8/4 8:23
     * @Param : []
     * @Return : si.yun.utils.JsonData
     */
    private SyProductCategroy SyCourseCategories(int c) {
        return syProductCategroyMapper.SyCourseCategories(c);
    }
    @Override
    public List<HashMap> SyCourseCommodityReviewSearch(String sss, int sss1, int sss2) {
        return SyProductMapper.SyCourseCommodityReviewSearch(sss,sss1,sss2);

    }

    @Override
    public List<HashMap> SyAdvancedSearchCourseReview(SyUser syUser) {
        Integer  user=syUserMapper.getUser_id(syUser.getFreestyle());
        List<HashMap> hashMaps = Mapper.SyAdvancedSearchCourseReview(syUser,user);

        return  hashMaps;
    }

    @Override
    public List<HashMap> SyPendingCommodityChindChaKan(int id) {
        return SyProductMapper.SyPendingCommodityChindChaKan(id);
    }

    @Override
    public List<HashMap> AdvancedSearchCourseReview(String remarks, int select1, String email, String position_id, int select2, String position) {
        return SyProductMapper.AdvancedSearchCourseReview(remarks, select1, email, position_id, select2);
    }

    @Override
    public int SyAllProducts() {
        return SyProductMapper.SyAllProducts();
    }

    @Override
    public int SyReviewedProducts() {
        return SyProductMapper.SyReviewedProducts();
    }

    @Override
    public int PendingProducts() {
        return SyProductMapper.PendingProducts();
    }

    @Override
    public int SyFailedProduct() {
        return SyProductMapper.SyFailedProduct();
    }

    @Override
    public List<Map<String, Object>> selCoupon(SyUserCoupon sc) {
        List<Map<String, Object>> list = syUserCouponMapper.selCoupon(sc);
        return list;
    }

    @Override
    public int delCoupon(Integer couponId) {
        int num = syUserCouponMapper.delCoupon(couponId);
        return num;
    }

    @Override
    public int addCoupon(SyUserCoupon sc) {
        int num = syUserCouponMapper.addCoupon(sc);
        return num;
    }

    @Override
    public int updCouponOnline(Integer online, Integer coupon_id) {
        int num = syUserCouponMapper.updCouponOnline(online, coupon_id);
        return num;
    }

    /**
     * @Description: 修改商品状态 李军瑶 10/14
     * @return: int
     * @Date: 2021/10/14 10:27
     */
    @Override
    public int updProductSate(Integer state, Integer productId) {
        int num = SyProductMapper.updProductSate(state, productId);
        return num;
    }

    @Override
    public List<Map<String, Object>> selCouponUsed(String account, String nickname, Integer user_id) {
        List<Map<String, Object>> list = syUserCouponUsedMapper.selCouponUsed(account,nickname,user_id);
        return list;
    }

    /**
     * @author: DZQ
     * @description: 查看轮播图
     * @date: 2021/10/12 13:57
     * @return
     */
    @Override
    public List<Map<String, Object>> selCarousel(Map<String, Object> map) {
        List<Map<String, Object>> list = syCarouselMapper.selCarousel(map);
        for(Map<String, Object> maps:list){
            maps.put("img_address",path1+maps.get("img_address"));
            maps.put("connect",path1+maps.get("connect"));

        }
        return list;
    }

    /**
   * @Description : 课程导入
   * @Return : int
   * @Date : 2021/9/8 10:23
   */
    @Override
    public int addCourseInsimport(List<SyCourse> list) {
        int num = Mapper.addCourseInsimport(list);
        return num;
    }
    /**
     * @Description : 查询课程
     * @Return : java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date : 2021/9/4 15:02
     */
    @Override
    public List<Map<String, Object>> selCourses(Map<String, Object> map) {
        List<Map<String, Object>> list = Mapper.selCourses(map);
        return list;
    }

    /**
       * @Description : 删除课程
       * @Return : int
       * @Date : 2021/9/7 18:49
       */
    @Override
    public int delCourse(Integer courseId) {
        int num = Mapper.delCourse(courseId);
        return num;
    }

    /**
     * @Description : 查询课程分类父
     * @Return : java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date : 2021/9/4 11:46
     */
    @Override
    public List<Map<String, Object>> selCourseClass() {
        List<Map<String, Object>> list=new ArrayList<>();

        List<Map<String, Object>> maps = Mapper.selCourseClass();
        for(Map<String, Object> map:maps){
            int id= (int) map.get("id");
            map.put("open",true);
            List<Map<String, Object>> child=selselCourseClassChild(id);
            map.put("children",child);
            list.add(map);
        }
        return list;
    }

    /**
    * @Description : 查询商品分类子
    * @Return : java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
    * @Date : 2021/9/4 11:46
    */
    public List<Map<String, Object>> selselCourseClassChild(int id) {
        List<Map<String, Object>> list = Mapper.selselCourseClassChild(id);
        if(list!=null){
            for(Map<String, Object> map:list){
                int id1= (int) map.get("id");
                map.put("open",true);
                List<Map<String, Object>> maps = selselCourseClassChild(id1);
                map.put("children",maps);
            }
        }
        return list;
    }

    /**
        * @Description : 添加课程分类
        * @Return : si.yun.entity.JsonData
        * @Date : 2021/9/4 14:25
        */
    @Override
    public int addCourseClass(SyCourseClass sc) {
        int num = Mapper.addCourseClass(sc);
        return num;
    }

    /**
     *
     * @Description 查看审核课程信息
     * @return si.yun.entity.JsonData
     * @Date 14:34 2021/8/4
     **/

    @Override
    public List<Map<String, Object>> selCourseAud() {
        return Mapper.selCourseAud();
    }


    /**
     *
     * @Description //课程审核的高级检索
     * @return si.yun.entity.JsonData
     * @Date 12:01 2021/8/5
     **/
    @Override
    public List<Map<String, Object>> selCourseHeight(SyCourse list) {
        return Mapper.selCourseHeight(list);
    }
    /**
     *
     * @Description //课程审核的详情
     * @return si.yun.entity.JsonData
     * @Date 12:01 2021/8/5
     **/
    @Override
    public Map<String, Object> selCoAuInfo(int courseNo) {
        return Mapper.selCoAuInfo(courseNo);
    }
    /**
     *
     * @Description //课程审核修改
     * @return si.yun.entity.JsonData
     * @Date 12:01 2021/8/5
     **/
    @Override
    public int upCourseCstatus(int result, int courseId) {
        return (int) Mapper.upCourseCstatus(result,courseId);
    }

    /**
       * @Description : 查询所有课程分类赋值给下拉菜单
       * @Return : java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
       * @Date : 2021/9/4 11:58
       */
    @Override
    public List<Map<String, Object>> selCourseClassSelect() {
        List<Map<String, Object>> list = Mapper.selCourseClassSelect();
        return list;
    }

    /**
      * @Description : 修改课程分类
      * @Return : int
      * @Date : 2021/9/4 14:24
      */
    @Override
    public int updCourseClass(SyCourseClass sc) {
        int num = Mapper.updCourseClass(sc);
        return num;
    }

    /**
     * @Description : 删除课程分类
     * @Return : int
     * @Date : 2021/9/4 14:24
     */
    @Override
    public int delCourseClass(Integer id) {
        int num = Mapper.delCourseClass(id);
        return num;
    }

    /**
     * @Description : 修改课程
     * @Return : int
     * @Date : 2021/9/7 14:22
     */
    @Override
    @Transactional
    public int updCourses(SyCourse sc) {
        int num = Mapper.updCourses(sc);
        //获取log_id
        Integer courseId = sc.getCourseId();
        //获取原价
        double price = sc.getCoursePrice();
        //获取现价
        double nprice = sc.getCourseNprice();

        Integer createId = sc.getCreateId();

        Map map=new HashMap();
        map.put("log_id",courseId);
        map.put("price",price);
        map.put("nprice",nprice);
        map.put("type",2);
        map.put("createId",createId);
        int num1 = addCourseLog(map);

        if(num==0||num1==0){
            throw new RuntimeException();
        }
        int sum=num+num1;
        return sum;
    }
    /**
       * @Description :添加课程日志
       * @Return : int
       * @Date : 2021/9/13 10:49
       */
    @Transactional
    public int addCourseLog(Map<String,Object> map){
        int num = Mapper.addCourseLog(map);
        return num;
    }

    /**
          * @Description : 课程日志
          * @Return : java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
          * @Date : 2021/9/13 9:54
          */
    @Override
    public List<Map<String, Object>> selCourseLog(Integer type, Integer log_id) {
        List<Map<String, Object>> list = Mapper.selCourseLog(log_id);
        return list;
    }
    /**
     * @Description : 通过课程分类子获取父分类
     * @Return : java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date : 2021/9/14 9:47
     */
    @Override
    public Map<String, Object> selCousrseChildParent(Integer id) {
        Map<String, Object> map = Mapper.selCousrseChildParent(id);
        return map;
    }
    /**
      * @Description : 添加课程
      * @Return : int
      * @Date : 2021/9/14 16:47
      */
     @Override
    @Transactional
    public int addCourse(SyCourse sc, List<SyMicrocircleImg> list1) {
        //添加课程
        int num = Mapper.addCourse(sc);
        //获取商品的id
        for(SyMicrocircleImg sm:list1){
            sm.setCommodityId(sc.getCourseId());
        }

        //添加课程预览图
        int num1=1;
        if(list1.size()>0){
            int addProductImg = addProductImg(list1);
            if(addProductImg==0){
                num1=0;
            }
        }

         //添加操作日志
         SyOperationLog log=new SyOperationLog();
         log.setTablename("课程列表");
         log.setType(2);
         log.setMid(sc.getCreateId());
         log.setRemark("添加课程");
         int num3 = addOperationLog(log);



         //添加日志
        Map<String,Object> map=new HashMap<>();
        map.put("logId",sc.getCourseId());
        map.put("price",sc.getCourseNprice());
        map.put("nprice",sc.getCourseNprice());
        map.put("type",2);
        map.put("createId",sc.getCreateId());
        int num2 = addLog(map);
        if(num==0||num1==0 || num2==0 ||num3==0){
            throw new RuntimeException();
        }
        int sum=num+num1+num2+num3;
        return sum;
    }

    /**
       * @Description : 添加时，并添加课程日志
       * @Return : int
       * @Date : 2021/9/14 20:56
       */
    @Transactional
    public int addLog(Map<String,Object> map){
        int num = Mapper.addLog(map);
        return num;
    }

    /*
     * @Description : 添加操作日志
     * @Return : int
     * @Date : 2022/1/5 9:08
     */
    @Transactional
    public int addOperationLog(SyOperationLog log){
        int num = personnelMapper.addOperationLog(log);
        return num;
    }


    /**
      * @Description : //添加商品预览图
      * @Return : int
      * @Date : 2021/8/14 20:34
      */
    @Transactional
    public int addProductImg(List<SyMicrocircleImg> list1) {
        int num1 = Mapper.addProductImg(list1);
        return num1;
    }
    /**
         * @Description : 查询审核记录
         * @Return : java.util.List<si.yun.entity.SyCourseRecord>
         * @Date : 2021/8/4 16:25
         */
    @Override
    public List<Map<String,Object>> selCourseRecord(Integer type, Integer course_id) {
        List<Map<String,Object>> list = syCourseRecordMapper.selCourseRecord(type, course_id);
        return list;
    }

    /**
     * @Description: 李军瑶商品审核详情
     * @return: java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date: 2021/10/13 15:11
     */
    @Override
    public List<Map<String, Object>> getAuditDetails(Integer type, Integer productId) {
        List<Map<String,Object>> list = syCourseRecordMapper.getAuditDetails(type, productId);
        return list;
    }

    /**
     * @Author : 栾佳俊
     * @Date : 2021/9/16 9:02
     * @Param :
     * @Return : 商品导入
     */
    @Override
    public int addInsimportExcel(List<SyProduct> list) {
        int num = SyProductMapper.addInsimportExcel(list);

        return num;
    }
    /**
     *
     * @Description   //查询所有商品分类赋值给下拉菜单
     * @return List<Map<String, Object>>
     * @Date 17:00 2021/8/4
     **/
    @Override
    public List<Map<String, Object>> selProductCategorySelect() {
        List<Map<String, Object>> maps = syProductCategroyMapper.selProductCategorySelect();
        return maps;
    }

    /**
     *
     * @Description //获取商品信息
     * @return List<Map<String, Object>>
     * @Date 17:00 2021/8/4
     **/
    @Override
    public List<Map<String, Object>> selProduct(@RequestParam Map<String,Object> map) {
        List<Map<String, Object>> maps = SyProductMapper.selProduct(map);
        return maps;
    }

    /**
     * @Description  //删除商品
     * @return List<Map<String, Object>>
     * @Date 17:00 2021/8/4
     **/
    @Override
    public int delProduct(Integer productId) {
        int num = SyProductMapper.delProduct(productId);
        return productId;
    }
	/**
     * @Description 删除商品  李军瑶  11/25
     * @return int
     * @Date 2021/11/25 11:41
     */
    @Override
    public int upProduct(Integer productId,Integer mid) {

        //添加操作日志
        SyOperationLog log=new SyOperationLog();
        log.setTablename("商品列表");
        log.setType(3);
        log.setMid(mid);
        log.setRemark("删除商品");
        int num3 = addOperationLog(log);

        int upPro = SyProductMapper.upProduct(productId);
        return upPro;
    }
    /**
     * @Description   查询商品分类父  李军瑶 11/10
     * @return List<Map<String, Object>>
     * @Date 17:00 2021/8/4
     **/
    @Override
    public List<Map<String, Object>> selProductCategory(Integer ParentId,Integer id ) {
        String curriculumTree=String. format(CacheKeyManager.INDEX_ProductCategory, ParentId, id);

        try {
            Object cache0bject=baseCache. getTenCacheBuild(). get(curriculumTree, ()-> {
                List<Map<String, Object>> list=new ArrayList<>();

                Map<String,Object> map1=new HashMap<>();
                map1.put("id",0);
                map1.put("name","选择分类类型");
                map1.put("open",true);

                List<Map<String, Object>> maps = syProductCategroyMapper.selProductCategory(ParentId);
                for(Map<String, Object> map:maps){

                    String str = (String) map.get("name");
                    if(str.length()>7){
                        String name=str.substring(0,7)+".....";
                        map.put("name",name);
                    }else{
                        map.put("name",str);
                    }

                    map.put("open",true);
                    int id1= (int) map.get("id");
                    List<Map<String, Object>> child=selProductCategoryChild(id1,id);
                    map.put("children",child);

                    if(map.get("id").equals(id)){
                        map.put("checked",true);
                    }
                }
                map1.put("children",maps);
                list.add(map1);
                return list;
            });
            if (cache0bject instanceof List ) {
                List<Map<String,Object>> list= (List<Map<String,Object>>) cache0bject;
                return list;
            }
        }catch(Exception e){
            e.printStackTrace();
        }
        return null;
    }


    /**
     * @Description   查询商品分类子  李军瑶 10/28
     * @return List<Map<String, Object>>
     * @Date 17:00 2021/8/4
     **/
    public List<Map<String, Object>> selProductCategoryChild(Integer id1,Integer id) {
        List<Map<String, Object>> list = syProductCategroyMapper.selProductCategory(id1);
        if(list!=null){
            for(Map<String, Object> map:list){

                String str = (String) map.get("name");
                if(str.length()>7){
                    String name=str.substring(0,7)+".....";
                    map.put("name",name);
                }else{
                    map.put("name",str);
                }

                map.put("open",true);
                int id2= (int) map.get("id");
                List<Map<String, Object>> maps = selProductCategoryChild(id2,id);
                map.put("children",maps);

                if(map.get("id").equals(id)){
                    map.put("checked",true);
                }
            }
        }
        return list;
    }
    /**
      * @Description : 添加商品分类  李军瑶  11/10
      * @Return : int
      * @Date : 2021/8/5 17:14
      */
    @Override
    public int addProductCategory(SyProductCategroy spc) {
        int num = syProductCategroyMapper.addProductCategory(spc);
        String curriculumTree=String.format(CacheKeyManager. INDEX_ProductCategory);
        if(num>0) {
            baseCache. invalidate(curriculumTree) ;
        }
        return num;
    }

    /**
      * @Description : 修改商品分类 李军瑶 11/10
      * @Return : int
      * @Date : 2021/8/5 19:26
      */
    @Override
    public int updProductCategory(String categroyName, Integer id,Integer updateUser) {
        int num = syProductCategroyMapper.updProductCategory(categroyName, id,updateUser);
        String curriculumTree=String.format(CacheKeyManager. INDEX_ProductCategory);
        if(num>0) {
            baseCache. invalidate(curriculumTree) ;
        }
        return num;
    }

    /**
      * @Description : 删除商品分类  李军瑶  11/10
      * @Return : int
      * @Date : 2021/8/5 19:46
      */
    @Override
    public int delProductCategory(Integer id) {
        int num = syProductCategroyMapper.delProductCategory(id);
        String curriculumTree=String.format(CacheKeyManager. INDEX_ProductCategory);
        if(num>0) {
            baseCache. invalidate(curriculumTree) ;
        }
        return num;
    }


    /**
     * @Description   //修改商品信息 李军瑶改 11/2
     * @return List<Map<String, Object>>
     * @Date 17:00 2021/8/4
     **/
    @Override
    @Transactional
    public int updProduct(ProductTable prta,List list1,List list2,List<Map<String, Object>> list3) {

        //删除预览图
        int delMicrocircleImg=1;
        if(list1.size()>0){
            int i = delMicrocircleImg(list1);
            if(i==0){
                delMicrocircleImg=0;
            }
        }
        
        //添加预览图
        int addMicrocircleImg=1;
        if(list2.size()>0){
            int i1 = addMicrocircleImg(list2);
            if(i1==0){
                addMicrocircleImg=0;
            }
        }

        //删除服务器图片
        if(list3.size()>0){
            for(Map<String,Object> map:list3){
                String delImg = (String) map.get("delImg");
                testAliUpload.delete(delImg);
            }
        }


        //添加操作日志
        SyOperationLog log=new SyOperationLog();
        log.setTablename("商品列表");
        log.setType(4);
        log.setMid(prta.getCreateUser());
        log.setRemark("修改商品");
        int addOperationLog = addOperationLog(log);


        int upPro= SyProductMapper.updProduct(prta);

        Map<String,Object> map=new HashMap<>();
        map.put("logId",prta.getProductId());
        map.put("price",prta.getOriginalpriceProduct());
        map.put("nprice",prta.getCurrentpriceProduct());
        map.put("type",3);
        map.put("createId",prta.getCreateUser());
        int num = addProductLog(map);

        if(upPro==0||num==0||delMicrocircleImg==0||addMicrocircleImg==0 ||addOperationLog==0){
            throw new RuntimeException();
        }
        int sum=upPro+num+delMicrocircleImg+addMicrocircleImg+addOperationLog;
        return sum;
    }

    /**
     * @Description : 删除预览图 李军瑶 12/15
     * @Return : int
     * @Date : 2021/12/14 14:14
     */
    @Transactional
    public int delMicrocircleImg(List list){
        int num= syForumMapper.delMicrocircleImg(list);
        return num;
    }
    /**
     * @Description : 添加预览图
     * @Return : int
     * @Date : 2021/12/14 14:16
     */
    @Transactional
    public int addMicrocircleImg(List list){
        int num= syForumMapper.addMicrocircleImg(list);
        return num;
    }
    /**
     * @Description:  添加商品操作日志  李军瑶 11/2
     * @return: int
     * @Date: 2021/11/2 9:36
     */
    @Transactional
    public int addProductLog(Map<String,Object> map){
        int num1 = SyProductMapper.addProductLog(map);
        return num1;
    }
    /**
    * @Description : 查看商品日志
    * @Return : java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
    * @Date : 2021/8/5 9:18
    */
    @Override
    public List<Map<String, Object>> selProductLog(ProductTable proTab) {
        List<Map<String, Object>> list = SyProductMapper.selProductLog(proTab);
        return list;
    }
    /**
   * @Description : 添加商品
   * @Return : int
   * @Date : 2021/8/12 21:12
   */
    @Override
    @Transactional
    public int addProduct(SyProduct sp, List<SyMicrocircleImg> list1) {
        //添加商品
        int num = SyProductMapper.addProduct(sp);
        //获取商品的id
        for(SyMicrocircleImg sm:list1){
            sm.setCommodityId(sp.getProductId());
        }

        //添加商品预览图
        int num1=1;
        if(list1.size()>0){
            int addProductImg = addProductImg(list1);
            if(addProductImg==0){
                num1=0;
            }
        }

        //添加操作日志
        SyOperationLog log=new SyOperationLog();
        log.setTablename("商品列表");
        log.setType(2);
        log.setMid(sp.getCreateUser());
        log.setRemark("添加商品");
        int addOperationLog = addOperationLog(log);


        //添加日志
        Map<String,Object> map=new HashMap<>();
        map.put("logId",sp.getProductId());
        map.put("price",sp.getCurrentpriceProduct());
        map.put("nprice",sp.getCurrentpriceProduct());
        map.put("type",3);
        int num2 = addLog(map);
        if(num==0||num1==0|| num2==0 || addOperationLog==0){
            throw new RuntimeException();
        }
        int sum=num+num1+num2+addOperationLog;
        return sum;
    }
    /**
     * @Description : 通过子获取父分类
     * @Return : java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date : 2021/8/6 13:59
     */
    @Override
    @Transactional
    public Map<String, Object> selChildParent(Integer id) {
        Map<String, Object> map = syProductCategroyMapper.selChildParent(id);
        return map;
    }
    /**
      * @Description : 赠送优惠券
      * @Return : int
      * @Date : 2021/9/1 11:54
      */
    @Override
    @Transactional
    public int addCouponUsed(List list) {
        int num2 = syUserCouponUsedMapper.addCouponUsed(list);
        int num1=addCouponUsed1(list);
        int num=num1+num2;
        return num;
    }
    /**
     * @author: DZQ
     * @description: 赠送优惠券总数减少
     * @date: 2021/10/10 18:44
     * @return
     */
    @Transactional
    public int addCouponUsed1(List list){
        int num1 = syUserCouponUsedMapper.addCouponUsed1(list);
        return num1;
    }
    /**
     * @Description : 查看轮播图记录
     * @Return : si.yun.entity.JsonData
    * @Date : 2021/8/27 11:25
     */
    @Override
    public List<Map<String, Object>> selCarouselPictures(Map<String ,Object> map) {
        List<Map<String, Object>> list = syCarouselMapper.selCarouselPictures(map);
        for(Map<String, Object> maps:list){
                maps.put("img_address",path1+maps.get("img_address"));
                maps.put("connect",path1+maps.get("connect"));
        }
        return list;
    }
    /**
       * @Description : 轮播与删除
       * @Return : si.yun.entity.JsonData
      * @Date : 2021/8/27 11:25
       */

    @Override
    public int DeleteCarousel(int carousel_id) {

        //删除服务器图片
        List<Map<String, Object>> list = syCarouselMapper.selCarouselImg(carousel_id);
        if(list.size()>0){
            for(Map<String,Object> map:list){
                String img_address = (String) map.get("img_address");
                //testAliUpload.delete(img_address);

                String connect = (String) map.get("connect");
                if(connect!=null){
                    testAliUpload.delete(connect);
                }
            }
        }
        return syCarouselMapper.DeleteCarousel(carousel_id);
    }

    /*
        * @Description : 修改轮播图上线\下线
        * @Return : int
        * @Date : 2021/9/22 16:27
        */
    @Override
    public int updCarouselDisplay(Integer display,Integer carousel_id) {
        int num = syCarouselMapper.updCarouselDisplay(display, carousel_id);
        return num;
    }

    /*
   * @Description : 修改轮播图
   * @Return : int
   * @Date : 2021/9/22 19:45
   */
    @Override
    public int updCarousel(Map<String ,Object> map) {
        int num = syCarouselMapper.updCarousel(map);
        return num;
    }

    /**
     * @author: DZQ
     * @description: 添加轮播图
     * @date: 2021/10/8 15:57
     * @return int
     */
    @Override
    public int addCarousel(Map<String,Object> map,String backImgNewName1) {

        return syCarouselMapper.addCarousel(map,backImgNewName1);
    }

    /**
         * @Description : 浏览记录
         * @Return : si.yun.entity.JsonData
        * @Date : 2021/8/27 11:25
         */
    @Override
    public Map<String, Object> selCurriculumCount() throws Exception {
        //获取周日期
        List<String> week = Utils.getWeek();
        Map<String,Object> map=new HashMap<>();
        //周
        List li1 = li(week);
        List list1 = li1(week,1);
        //日
        List<String> day = Utils.getDay(1);
        day.remove(day.size()-1);
        List li2 = li(day);
        List<String> day1 = Utils.getDay(0);
        List list2 = li1(day1,2);
        //周
        map.put("week",li1);
        map.put("weekData",list1);
        //日
        map.put("day",li2);
        map.put("dayData",list2);
        //月
        List<Integer> month = Utils.getMonth();
        List<String> dayListOfMonth = Utils.getDayListOfMonth(0);
        String perFirstDayOfMonth = Utils.getPerFirstDayOfMonth();
        List<String> i=new ArrayList<>();
        i.addAll(dayListOfMonth);
        i.add(perFirstDayOfMonth);
        List li3 = li(i);
        //月
        map.put("month",li3);
        map.put("monthData",month);
        return map;
    }

    @Override
    public Map<String, Object> selPageSystem() {
        //获取周日期
        List<String> week = Utils.getWeek();
        Map<String,Object> map=new HashMap<>();
        //周
        List li1 = li(week);
        List list1 = li2(week,1);
        //日
        List<String> day = null;
        try {
            day = Utils.getDay(1);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        day.remove(day.size()-1);
        List li2 = li3(day);
        List<String> day1 = null;
        try {
            day1 = Utils.getDay(0);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        List list2 = li1(day1,2);
        //周
        map.put("week",li1);
        map.put("weekData",list1);
        //日
        map.put("day",li2);
        map.put("dayData",list2);
        //月
        List<Integer> month = null;
        try {
            month = Utils.getMonth();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        List<String> dayListOfMonth = Utils.getDayListOfMonth(0);
        String perFirstDayOfMonth = Utils.getPerFirstDayOfMonth();
        List<String> i=new ArrayList<>();
        i.addAll(dayListOfMonth);
        i.add(perFirstDayOfMonth);
        List li3 = li(i);
        //月
        map.put("month",li3);
        map.put("monthData",month);
        return map;
    }

    @Override
    public List<Map<String, Object>> selCommentCount(Integer type,Integer userType) {
        return syCommentMapper.selCommentCount(type,userType);
    }

    /**
     * @Description : 统计历史/今天数量
     * @Return : java.util.Map<java.lang.String,java.lang.Object>
     * @Date : 2021/9/23 15:41
     */
    @Override
    public Map<String, Object> historyTodayCount(Integer type) {
        Map<String,Object> map=new HashMap<>();
        Integer historyCount = syCommentMapper.historyCount(type);
        Integer historyNumber = syCommentMapper.historyNumber(type);
        Integer todayCount = syCommentMapper.todayCount(type);
        Integer todayNumber = syCommentMapper.todayNumber(type);
        map.put("historyCount",historyCount);
        map.put("historyNumber",historyNumber);
        map.put("todayCount",todayCount);
        map.put("todayNumber",todayNumber);
        return map;
    }
    /**
    * @Description : 查询评论
    * @Return : java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
    * @Date : 2021/9/23 10:27
    */
    @Override
    public List<Map<String, Object>> selComment(Integer type,Integer status,Integer userType) {
        List<Map<String, Object>> list = syCommentMapper.selComment(type,status,userType);
        return list;
    }
    @Override
    public List<Map<String, Object>> selBackComment(Integer type, Integer status, Integer userType) {
        List<Map<String, Object>> list = syCommentMapper.selBackComment(type,status,userType);
        return list;
    }
    /**
      * @Description : 评论状态修改
      * @Return : int
      * @Date : 2021/9/23 16:20
      */
    @Override
    public int updComment(Integer status, Integer id) {
        int num = syCommentMapper.updComment(status, id);
        return num;
    }
    /**
     * @Author : 栾佳俊
     * @Date : 2021/9/8 11:48
     * @Param : [week]
     * @Return : java.util.List
     * 处理日期减1
     */
    public List li1(List<String> week,int a){
        List<String> list=new ArrayList<>();
        for (int i = 0; i <week.size() - a; i++) {
            list.add(week.get(i));
        }
        return list;
    }
    /**
     * @Author : 栾佳俊
     * @Date : 2021/9/8 11:48
     * @Param : [week]
     * @Return : java.util.List
     * 获取日期相对应数据
     */
    public List li(List<String> week){
        String i = null;
        List<String> list=new ArrayList<>();
        for(int a=0;a<week.size()-1;a++){
            String s = week.get(a);
            String s1 = week.get(a + 1);
            i=syUserCollection.selCurriculumCount(s,s1);
            list.add(i);
        }
        return list;
    }
    /**
     * @Author : 栾佳俊
     * @Date : 2021/9/8 11:48
     * @Param : [week]
     * @Return : java.util.List
     * 处理日期减1
     */
    public List li2(List<String> week,int a){
        List<String> list=new ArrayList<>();
        for (int i = 0; i <week.size() - a; i++) {
            list.add(week.get(i));
        }
        return list;
    }
    /**
     * @Author : 栾佳俊
     * @Date : 2021/9/8 11:48
     * @Param : [week]
     * @Return : java.util.List
     * 获取日期相对应数据
     */
    public List li3(List<String> week){
        String i = null;
        List<String> list=new ArrayList<>();
        for(int a=0;a<week.size()-1;a++){
            String s = week.get(a);
            String s1 = week.get(a + 1);
            i=syUserCollection.selPageSystem(s,s1);
            list.add(i);
        }
        return list;
    }
    /**
     * @Description : 查询商品订单列表
     * @Return : java.util.List<si.yun.entity.SyCourseRecord>
     * @Date : 2021/8/4 16:25
     */
    @Override
    public List<Map<String, Object>> selProductOrderList(Map<String ,Object> m) {
        return  SyUserOrderMapper.selProductOrderList(m);
    }
    /**
     * @Description : 高级检索查询商品订单列表
     * @Return : java.util.List<si.yun.entity.SyCourseRecord>
     * @Date : 2021/8/4 16:25
     */
    @Override
    public List<Map<String, Object>> selProductOrderList1(Map<String, Object> m) {
        return  SyUserOrderMapper.selProductOrderList1(m);
    }
    /**
     * @Description : 商品订单列表的查看
     * @Return : java.util.List<si.yun.entity.SyCourseRecord>
     * @Date : 2021/8/4 16:25
     */
    @Override
    public Map<String, Object> selProductOrderDetails(String orderId) {
        return SyUserOrderMapper.selProductOrderDetails(orderId);
    }
    /**
     * @Description : 商品订单列表的删除
     * @Return : java.util.List<si.yun.entity.SyCourseRecord>
     * @Date : 2021/8/4 16:25
     */
    @Override
    public int delProductOrderDetails(String orderId) {
        return SyUserOrderMapper.delProductOrderDetails(orderId);
    }
    /**
     * @Description : 查询商品订单待付款列表
     * @Return : java.util.List<si.yun.entity.SyCourseRecord>
     * @Date : 2021/8/4 16:25
     */
    @Override
    public List<Map<String, Object>> selGoodsPaidList(Map<String, Object> m) {
        return SyUserOrderMapper.selGoodsPaidList(m);
    }
    /**
     * @Description : 查询课程订单列表数据
     * @Return : java.util.List<si.yun.entity.SyCourseRecord>
     * @Date : 2021/8/4 16:25
     */
    @Override
    public List<Map<String, Object>> selCourseOrderListData(Map<String ,Object> m) {
        return  SyUserOrderMapper.selCourseOrderListData(m);
    }
    /**
     * @Description : 查询课程订单列表数据详情
     * @Return : java.util.List<si.yun.entity.SyCourseRecord>
     * @Date : 2021/8/4 16:25
     */
    @Override
    public Map<String, Object> selCourseOrderList(Map<String ,Object> m) {
        return  SyUserOrderMapper.selCourseOrderList(m);
    }
	/**
     * @Description: 删除个人商品 10/18  李军瑶
     * @return: int
     * @Date: 2021/10/18 11:36
     */
    @Override
    public int delPersonalProductList(Integer productId) {
        int del = SyUserOrderMapper.delPersonalProductList(productId);
        return del;
    }
	/**
     * @Description 删除个人商品2 11/25  李军瑶
     * @return int
     * @Date 2021/11/25 11:53
     */
    @Override
    public int upPersonalProductList(Integer productId) {
        int upPer = SyUserOrderMapper.upPersonalProductList(productId);
        return upPer;
    }
	/**
     * @Description: 修改商品审核状态  李军瑶 11/3
     * @return: int
     * @Date: 2021/11/3 20:26
     */
    @Override
    public int upProductSate(Integer productSate, Integer productId) {
        int upPro = SyUserOrderMapper.upProductSate(productSate, productId);
        return upPro;
    }
    /**
     * @Description : 查询个人商品列表
     * @Return : java.util.List<si.yun.entity.SyCourseRecord>
     * @Date : 2021/8/4 16:25
     */
    @Override
    public List<Map<String,Object>> selPersonalProductList(Map<String, Object> m) {
        return SyUserOrderMapper.selPersonalProductList(m);
    }
    @Override
    public List<Map<String, Object>> selBolk(Integer type, Integer status) {
        return Mapper.selCommentCount(type,status);
    }
    /**
     * @Description  彻底删除评论
     * @return java.lang.Integer
     * @Date 2021/10/7 15:04
     **/
    @Override
    public Integer clearComment(Integer id) {
        Integer del = syCommentMapper.clearComment(id);
        return del;
    }


    /**
     * @Description 商品审核列表
     * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date 11:17 2021/8/15
     */
    @Override
    public List<Map<String, Object>> getCommodityAudit(ProductTable protab) {
        List commodityAudit = SyProductMapper.getCommodityAudit(protab);
        return commodityAudit;
    }

    /**
     * @Description 统计审核状态的商品数量
     * @return int
     * @Date 17:03 2021/8/15
     */
    @Override
    public int getStatisticalAuditStatus(Integer productSate) {
        int status = SyProductMapper.getStatisticalAuditStatus(productSate);
        return status;
    }

     /**
     * @Description 商品审核弹出层    李军瑶 11/3
     * @return int
     * @Date 11:58 2021/8/17
     */
    @Transactional
    @Override
    public int setCommodityAudit(Integer state,Integer productSate, Integer productId,Integer implementId,String result,String details,Integer type) throws Exception {
        //商品审核
        int comaud= SyProductMapper.setCommodityAudit(state,productSate, productId);
        //添加商品审核记录
        int i = addAuditLogGing(productId,implementId, result, details, type);
        if(comaud==0||i==0){
            throw new Exception();
        }else{
            return comaud+i;
        }
    }
    /**
     * @Description 添加商品审核记录   李军瑶 11/3
     * @return int
     * @Date 11:58 2021/8/17
     */
    @Transactional
    public int addAuditLogGing( Integer productId,Integer implementId,String result,String details,Integer type) {
        //添加商品审核记录
        int audlog = SyProductMapper.addAuditLogGing(productId,implementId, result, details, type);
        return audlog;
    }

    /**
     * @Description  查看单个课程的详情信息
     * @return si.yun.entity.SyCourseTab
     * @Date 2021/10/7 15:49
     **/
    @Override
    @Transactional
     public SyCourseTab selcourse(Integer courseId) {
        SyCourseTab selcourse = syCommentMapper.selcourse(courseId);

        List<Map<String,Object>> list = selMicrocircleImg(2, courseId);

        selcourse.setMicrocircleImg(list);

        return selcourse;
    }

    @Transactional
    public List selMicrocircleImg(Integer type,Integer id){
        List<Map<String,Object>> list = syCommentMapper.selMicrocircleImg(type, id);
        for(Map<String,Object> map:list){
            map.put("picture_url",path1+map.get("picture_url"));
        }
        return list;
    }


    /**
     * @Description  课程详情下的评论区
     * @return java.util.List<si.yun.entity.SyCommentList>
     * @Date 2021/10/7 19:09
     **/
    @Override
    public List<SyCommentList> selCommentInfo(Integer id,Integer type) {
        List<SyCommentList> back = syCommentMapper.selBackCommentInfo(id,type);
        List<SyCommentList> before = syCommentMapper.selBeforeCommentInfo(id,type);
        List<SyCommentList> list = new LinkedList<>();

        KeyWordFilter.initPattern();

        for(SyCommentList li:back){
            String str = KeyWordFilter.doFilter2(li.getContent());
            li.setContent(str);
            li.setUserImg(path1+li.getUserImg());
            list.add(li);
        }
        for(SyCommentList li:before){
            String str = KeyWordFilter.doFilter2(li.getContent());
            li.setContent(str);

            if(li.getUserImg()!=null){
                if(!li.getUserImg().startsWith("https:")){
                    li.setUserImg(path1+li.getUserImg());
                }
            }
            list.add(li);
        }
        return list;
    }
    /**
     * @Description  添加评论
     * @return java.lang.Integer
     * @Date 2021/10/7 20:26
     **/
    @Override
    public Integer addCommentInfo(SyComment comment) {
        Integer add = syCommentMapper.addCommentInfo(comment);
        return add;
    }

    /**
     * @Description  查询评论 文章 前后端
     * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date 2021/10/8 9:00
     **/
    @Override
    public List<Map<String, Object>> selEssayComment(Integer type,Integer status,Integer userType) {
        List<Map<String, Object>> list = syCommentMapper.selEssayComment(type,status,userType);
        return list;
    }
    @Override
    public List<Map<String, Object>> selEssayBackComment(Integer type, Integer status, Integer userType) {
        List<Map<String, Object>> list = syCommentMapper.selEssayBackComment(type,status,userType);
        return list;
    }
    /**
     * @Description  查看文章详情
     * @return si.yun.entity.OperEassyInfo
     * @Date 2021/10/8 10:26
     **/
    @Override
    public OperEassyInfo selEassyInfo(Integer microcircleId) {
        OperEassyInfo operEassyInfo = syCommentMapper.selEassyInfo(microcircleId);
        operEassyInfo.setArticleUrl(path1+operEassyInfo.getArticleUrl());
        return operEassyInfo;
    }
    /**
     * @Description  获取用户信息
     * @return java.util.Map<java.lang.String,java.lang.Object>
     * @Date 2021/10/8 10:32
     **/
    @Override
    public Map<String, Object> seluserInfos(String tableName, String tableInfo, Integer userId) {
        Map<String, Object> stringObjectMap = syCommentMapper.seluserInfos(tableName, tableInfo, userId);
        return stringObjectMap;
    }
    /**
     * @Description  获取文章中包含的图片
     * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date 2021/10/8 11:03
     **/
    @Override
    public List<Map<String, Object>> selEassyImgs(Integer microcircleId,Integer pictureType) {
        List<Map<String, Object>> list = syCommentMapper.selEassyImgs(microcircleId,pictureType);
        for(Map<String,Object> li:list){
            li.put("articleUrl",path1+li.get("articleUrl"));
        }
        return list;
    }

    /**
     * @Description  获取商品评论的信息
     * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date 2021/10/8 13:42
     **/
    @Override
    public List<Map<String, Object>> selCommodityComment(Integer type,Integer status,Integer userType) {
        List<Map<String, Object>> list = syCommentMapper.selCommodityComment(type,status,userType);
        return list;
    }
    @Override
    public List<Map<String, Object>> selCommodityBackComment(Integer type, Integer status, Integer userType) {
        List<Map<String, Object>> list = syCommentMapper.selCommodityBackComment(type,status,userType);
        return list;
    }
    /**
     * @Description  获取商品详细信息  12/14
     * @return si.yun.entity.OperCommodityInfo
     * @Date 2021/10/8 14:26
     **/
    @Override
    public OperCommodityInfo selCommodityInfo(Integer microcircleId) {
        OperCommodityInfo operEassyInfo = syCommentMapper.selCommodityInfo(microcircleId);
        operEassyInfo.setMainImage(path1+operEassyInfo.getMainImage());

        List<Map<String, Object>> list = selMicrocircleImg1( 1,microcircleId);
        operEassyInfo.setMicrocircleImg(list);
        return operEassyInfo;
    }
    @Transactional
    public List<Map<String, Object>> selMicrocircleImg1(Integer type, Integer id) {
        List<Map<String, Object>> list = syCommentMapper.selMicrocircleImg(type, id);
        for (Map<String, Object> map : list) {
            map.put("picture_url", path1+map.get("picture_url"));
        }
        return list;
    }
    /**
     * @Description  获取商品中包含的图片
     * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date 2021/10/8 11:03
     **/
    @Override
    public List<Map<String, Object>> selCommodityImgs(Integer microcircleId,Integer pictureType) {
        List<Map<String, Object>> list = syCommentMapper.selCommodityImgs(microcircleId,pictureType);
        for(Map<String,Object> li:list){
            li.put("articleUrl",path1+li.get("articleUrl"));
        }
        return list;
    }
    /**
     * @Description  获取个人评论统计数量（课程  文章  商品）
     * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date 2021/10/10 19:06
     **/
    @Override
    public List<Map<String, Object>> getCourseCountNum(Integer userId, Integer userType) {
        List<Map<String, Object>> courseCountNum = syCommentMapper.getCourseCountNum(userId, userType);
        return courseCountNum;
    }
    @Override
    public List<Map<String, Object>> getEssayCountNum(Integer userId, Integer userType) {
        List<Map<String, Object>> essayCountNum = syCommentMapper.getEssayCountNum(userId, userType);
        return essayCountNum;
    }
    @Override
    public List<Map<String, Object>> getProductCourseCountNum(Integer userId, Integer userType) {
        List<Map<String, Object>> productCourseCountNum = syCommentMapper.getProductCourseCountNum(userId, userType);
        return productCourseCountNum;
    }
    /**
     * @Description  获取个人课程的评论数据  前后
     * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date 2021/10/10 19:17
     **/
    @Override
    public List<Map<String, Object>> getCourseBeforeAjax(Integer userId, Integer status, Integer userType) {
        List<Map<String, Object>> list = syCommentMapper.getCourseBeforeAjax(userId, status, userType);
        return list;
    }
    @Override
    public List<Map<String, Object>> getCourseBackAjax(Integer userId, Integer status, Integer userType) {
        List<Map<String, Object>> list = syCommentMapper.getCourseBackAjax(userId, status, userType);
        return list;
    }
    /**
     * @Description  获取个人文章的评论数据 前后
     * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date 2021/10/8 17:02
     **/
    @Override
    public List<Map<String, Object>> selPerBackEasComment(Integer userId, Integer status, Integer userType) {
        List<Map<String, Object>> list = syCommentMapper.selPerBackEasComment(userId, status, userType);
        return list;
    }
    @Override
    public List<Map<String, Object>> selPerBeforeEasComment(Integer userId, Integer status, Integer userType) {
        List<Map<String, Object>> list = syCommentMapper.selPerBeforeEasComment(userId, status, userType);
        return list;
    }
    /**
     * @Description  获取个人商品评论的信息 前后
     * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date 2021/10/10 19:28
     **/
    @Override
    public List<Map<String, Object>> getCommodityBeforeAjax(Integer userId, Integer status, Integer userType) {
        List<Map<String, Object>> commodityBeforeAjax = syCommentMapper.getCommodityBeforeAjax(userId, status, userType);
        return commodityBeforeAjax;
    }
    @Override
    public List<Map<String, Object>> getCommodityBackAjax(Integer userId, Integer status, Integer userType) {
        List<Map<String, Object>> commodityBackAjax = syCommentMapper.getCommodityBackAjax(userId, status, userType);
        return commodityBackAjax;
    }
	/**
     * @Description 课程订单详情   李军瑶  11/16
     * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date 2021/11/16 14:58
     */
    @Override
    public List<Map<String, Object>> selCourseOrderLists(Integer orderId) {
        List<Map<String, Object>> maps = SyUserOrderMapper.selCourseOrderLists(orderId);
        return maps;
    }

    /**
     * @Description 商品订单列表   李军瑶  11/8
     * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date 16:46 2021/8/24
     */
    @Override
    public List<Map<String, Object>> addOrdersGoods(ProductTable protab) {
        List list = SyUserOrderMapper.addOrdersGoods(protab);
        return list;
    }
    /**
     * @Author: LJY
     * @Description: 统计商品订单数量   李军瑶  11/8
     * @return:int
     * @Date:11:06 2021/9/9
     */
    @Override
    public int getOrderNumber(Integer orderType, Integer orderStatus) {
        int orderNumber = SyUserOrderMapper.getOrderNumber(orderType, orderStatus);
        return orderNumber;
    }



    /**
     * @Description: 商品订单详情   李军瑶   11/11
     * @return:java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date:16:45 2021/9/9
     */
    @Override
    public List<Map<String, Object>> getOrderDetails(Integer orderId) {
        List<Map<String, Object>> orderDetails = SyUserOrderMapper.getOrderDetails(orderId);
        return orderDetails;
    }
	
	/**
     * @Description 修改订单状态  李军瑶 11/24
     * @return int
     * @Date 2021/11/24 11:10
     */
    @Override
    public int upOrderStatus(String orderStatus, Integer orderId) {
        int orderStatu = SyUserOrderMapper.upOrderStatus(orderStatus, orderId);
        return orderStatu;
    }
    /**
     * @Description: 修改收件人信息   李军瑶   11/11
     * @return: int
     * @Date: 2021/9/23 17:01
     */
    @Override
    public int setAddress(String address, Integer orderId) {
        int ddress = SyUserOrderMapper.setAddress(address, orderId);
        return ddress;
    }
    /**
     * @Description: 获取收件人地址   李军瑶   11/11
     * @return: java.util.Map<java.lang.String,java.lang.Object>
     * @Date: 2021/9/29 10:55
     */
    @Override
    public Map<String, Object> getAddress(Integer orderId) {
        Map<String, Object> address = SyUserOrderMapper.getAddress(orderId);
        return address;
    }


    /**
     * @Description   商品分类
     * @return List<Map<String, Object>>
     * @Date 17:00 2021/8/4
     **/
    @Override
    public List<Map<String, Object>> selProductCategory2(Integer ParentId,Integer id ) {
        List<Map<String, Object>> list=new ArrayList<>();

        Map<String,Object> map1=new HashMap<>();
        map1.put("id",0);
        map1.put("name","选择分类类型");
        map1.put("open",true);

        List<Map<String, Object>> maps = syProductCategroyMapper.selProductCategory(ParentId);
        for(Map<String, Object> map:maps){

            String str = (String) map.get("name");
            if(str.length()>7){
                String name=str.substring(0,7)+".....";
                map.put("name",name);
            }else{
                map.put("name",str);
            }

            map.put("open",true);
            int id1= (int) map.get("id");
            List<Map<String, Object>> child=selProductCategoryChild(id1,id);
            map.put("children",child);

            if(map.get("id").equals(id)){
                map.put("checked",true);
            }
        }
        map1.put("children",maps);
        list.add(map1);
        return list;
    }
	
	/**
     * @Description 退货订单列表   李军瑶 11/19
     * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date 2021/11/19 11:49
     */
    @Override
    public List<Map<String, Object>> returnGoods(ProductTable protab) {
        List<Map<String, Object>> maps = SyUserOrderMapper.returnGoods(protab);
        return maps;
    }
    /**
     * @Description 统计退货订单数量    李军瑶  11/19
     * @return int
     * @Date 2021/11/19 11:51
     */
    @Override
    public int getReturnGoodsNumber(Integer orderStatus) {
        int returnGoodsNumber = SyUserOrderMapper.getReturnGoodsNumber(orderStatus);
        return returnGoodsNumber;
    }

    /**
     * @Description 商品退货订单审核 李军瑶 11/22
     * @return int
     * @Date 2021/11/22 16:36
     */
    @Transactional
    @Override
    public int setOrderAudit(Integer productId,Integer orderStatus,Integer orderId,Integer implementId,String result,String details,Integer type) throws Exception {
        System.out.println(1);
        //商品审核
        int comaud= SyUserOrderMapper.setOrderAudit(orderStatus, orderId);
        //添加商品审核记录
        int i = addOrderAuditLog(productId,implementId, result, details, type);
        if(comaud==0||i==0){
            throw new Exception();
        }else{
            return comaud+i;
        }
    }

    /**
     * @Description 添加审核记录  李军瑶 11/22
     * @return int
     * @Date 2021/11/22 16:37
     */
    @Transactional
    public int addOrderAuditLog( Integer productId,Integer implementId,String result,String details,Integer type) {
        //添加商品审核记录
        int audlog = SyUserOrderMapper.addOrderAuditLog(productId,implementId, result, details, type);
        return audlog;
    }

    /**
     * @Description : 查询前台单个课程详情
     * @Return : si.yun.entity.SyCourseTab
     * @Date : 2021/11/29 8:46
     */
    @Override
    public SyCourseTab selBeforeCourse(Integer courseId) {
        SyCourseTab syCourseTab = syCommentMapper.selBeforeCourse(courseId);
        return syCourseTab;
    }
	
	/**
     * @Description  获取商品修改详情
     * @return si.yun.entity.ProductTable
     * @Date 2021/12/15 11:56
     */
    @Override
    public ProductTable selProducts(Integer productId) {
        ProductTable operCommodityInfo = SyProductMapper.selProducts(productId);

        List<Map<String, Object>> list = selMicrocircleImg1( 1,productId);
        operCommodityInfo.setMicrocircleImg(list);
        return operCommodityInfo;
    }
    /**
     * @Description 获取预览图
     * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date 2021/12/15 11:57 
     */
    @Transactional
    public List<Map<String, Object>> selMicrocircleImg2(Integer type, Integer id) {
        List<Map<String, Object>> list = syCommentMapper.selMicrocircleImg(type, id);
        for (Map<String, Object> map : list) {
            map.put("picture_url", path1+map.get("picture_url"));
        }
        return list;
    }

}
